home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <time.h>
- #define INT(x) (x-floor(x)>=0.5)?(int)ceil(x):(int)floor(x)
-
- void main (void)
- {
- unsigned long line[32]; /* Le bitmap */
- long epoch; /* gestion de */
- struct tm *tp; /* l'heure */
- double x,y, heure, minute; /* les coordonnees et l'heure */
- int j, i;
- char res[8], tmp[10];
-
- /* Creation de l'entete */
-
- printf ("Content-type: image/x-xbitmap%c%c",10,10);
-
- /* Creation du corps */
- printf("#define count_width 32\n");
- printf("#define count_height 32\n");
- printf("static char count_bits[] = {\n");
-
- /* Mise a zero */
- for (j=0; j<32; j++) line[j]=0;
-
- /* On dessine le cadran de l'horloge */
- for (i=0; i<12; i++) {
- for (j=15; j>=15-2*(i%3==0)?1:0; j--) {
- x=16+j*cos(M_PI*i/6);
- y=16+j*sin(M_PI*i/6);
- line[INT(y)]= line[INT(y)] | (unsigned long)pow(2.0,(double)INT(x));
- }
- }
-
- /* On recupere l'heure */
- time(&epoch);
- tp = localtime (&epoch);
- strftime(tmp, 10, "%M", tp);
- minute=atoi(tmp);
- strftime(tmp, 10, "%I", tp);
- heure=atoi(tmp)+minute/60;
-
- /* On dessine les aiguilles */
- for (i=-2; i<=9; i++) {
- x=16+i*cos(M_PI*heure/6-M_PI_2);
- y=16+i*sin(M_PI*heure/6-M_PI_2);
- line[INT(y)]= line[INT(y)] | (unsigned long)pow(2.0,(double)INT(x));
- }
- for (i=-2; i<=15; i++) {
- x=16+i*cos(M_PI*minute/30-M_PI_2);
- y=16+i*sin(M_PI*minute/30-M_PI_2);
- line[INT(y)]= line[INT(y)] | (unsigned long)pow(2.0,(double)INT(x));
- }
-
- /* On ecrit le bitmap sur la sortie standard */
- for (i=0; i<32; i++) {
- sprintf(res, "%08x", line[i]);
- for (j=3; j>=0; j--)
- if (i==31&&j==0) printf("0x%c%c};\n", res[2*j], res[2*j+1]);
- else printf("0x%c%c,", res[2*j], res[2*j+1]);
- }
- }
-